package com.wash.shoes.controller.app;

import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.domain.model.LoginBody;
import com.ruoyi.framework.web.service.SysLoginService;
import com.wash.shoes.service.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author lijianguo
 * @Date 21/09/2024 APP首页的数据
 * 请输入类的简介
 **/
@Api(tags = {"APP-首页"})
@RestController
@RequestMapping("app/")
public class FirstLoginAController {

    @Autowired
    OrderService orderService;

    @Autowired
    private SysLoginService loginService;

    @ApiOperation("获首页统计的数据")
    @GetMapping("/firstCount")
    public R<Map> firstCount(String beginDate) {
        Map dataCount = orderService.firstCount(beginDate);
        return R.ok(dataCount);
    }

    @ApiOperation("APP的登录获取token-uuid用APPID开始")
    @PostMapping("/appLogin")
    public AjaxResult appLogin(@RequestBody LoginBody loginBody) {
        AjaxResult ajax = AjaxResult.success();
        // 生成令牌
        String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
                loginBody.getUuid());
        ajax.put(Constants.TOKEN, token);
        return ajax;
    }
}
